$(function () {
    console.log('这个页面的节点初始化完成');
    axios.get('http://localhost:3000/films').then(res => {
        let data = res.data;
        console.log(data);
        data.data.forEach(item => {
            let tb = $('.tb');
            let html = `
                <tr>
                    <td>${item.id}</td>
                    <td>${item.filmName}</td>
                    <td>${item.director}</td>
                    <td>${item.actor}</td>
                    <td>${item.score}</td>
                    <td>${item.flag}</td>
                    <td>
                        <input type="button" value="编辑" onclick="btnEdit()">
                        <input type="button" value="删除" onclick="btnDel()">
                    </td>
                </tr>
            `
            tb.append(html);
        })
    })
})

function btnDel() {
    console.log('我是删除');
    axios.delete('http://localhost:3000/users/18', { username: 'admin', passowrd: '113' }).then(res => {
        console.log(res);
    })

}

function btnAdd() {
    console.log('新增');
    location.href = './edit.html'
}
function btnQuery() {
    console.log('查找');
}
function btnEdit() {
    console.log('编辑');
    location.href = './edit.html'
}